//
//  EATabBarController.m
//  WhatToEat
//
//  Created by Mac on 15/3/26.
//  Copyright (c) 2015年 Mac. All rights reserved.
//
#import "AppDelegate.h"
#import "EATabBarController.h"
//#import "FLEXManager.h"
@interface EATabBarController ()

@end

@implementation EATabBarController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
//    self.delegate=self;
//[[FLEXManager sharedManager] showExplorer];
    [self initTabbarView];
}

-(void)initTabbarView{
    
    NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomTabBarView" owner:self options:nil];
    self.customTabBarView = [nibObjects objectAtIndex:0];
    self.customTabBarView.delegate = self;
    [self.customTabBarView initView];
    
    CGRect r = self.customTabBarView.frame;
 //   r.origin.y = self.view.frame.size.height - self.customTabBarView.frame.size.height ;
    self.customTabBarView.frame = r;
    [self.tabBar addSubview:self.customTabBarView];
}

#pragma mark CustomTabBarViewDelegate

-(void)buttonWasSelected:(NSInteger)index {
    
    
    self.hidesBottomBarWhenPushed=NO;
    
    self.tabBar.hidden=NO;
    
    [self.customTabBarView buttonWasSelected:index];
    [self setSelectedIndex:index];



    if (index==0&&ApplicationDelegate.isToRoot==YES) {
        
        UINavigationController *lvc=(UINavigationController *)self.selectedViewController;
        
        
        
        
        for (UIViewController * vc in lvc.viewControllers) {
            
            
            vc.hidesBottomBarWhenPushed=NO;
            
        }

        
        
        [lvc popToRootViewControllerAnimated:YES];

        
        
        
    }
    

    

}

@end
